import { NextRequest, NextResponse } from "next/server";
import { prisma } from "prisma/client";

type Params = { params: { id: string } }
export async function POST(request: NextRequest, { params }: Params) {
  const intId = parseInt(params.id)
  const product = await prisma.product.findUnique({ where: { id: intId } })
  const updatedProduct = await prisma.product.update({
    where: { id: intId },
    data: {
      isDifferent: !product?.isDifferent
    }
  })

  return NextResponse.json(updatedProduct)
}